home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5381 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: ix.netcom.com!netnews
  2. From: a1s@ix.netcom.com (Andrew Snyder)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Who's dumb: me or my compiler ?
  5. Date: Mon, 12 Feb 1996 22:07:26 GMT
  6. Organization: Netcom
  7. Message-ID: <4fo3ci$nt1@cloner2.ix.netcom.com>
  8. References: <4fnmhd$c1o@micky.ibh-dd.de>
  9. NNTP-Posting-Host: ix-har5-06.ix.netcom.com
  10. X-NETCOM-Date: Mon Feb 12 11:11:14 AM PST 1996
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. beck@duck.ibh-dd.de (Andre Beck) wrote:
  14.  
  15. >Hi,
  16.  
  17. >I could have had a really bad day searching for this bug, but for
  18. >some lucky circumstances, I trapped it instantly. However I don't
  19. >know whether I wrote bad code or whether a number of compilers do
  20. >it wrong in the same way - the latter doesn't sound that probable ;)
  21.  
  22. >My problem turns around the expression
  23.  
  24. > x = (*ptr++ << 8) | *ptr++;
  25.  
  26. --snip
  27.  
  28. Its you who is dumb.  Anybody who expects an expression with the form
  29. A = B++ + B++ to behave is looking for trouble.  The compiler doesn't
  30. have to guarentee you anything about when both postfixs are processed.
  31.  
  32. try
  33.  x = *ptr++ <<8;
  34. x |= *ptr++;
  35. Andrew Snyder
  36. a1s@ix.netcom.com
  37. char disclaimer[] = {'\0'}; /* I'm on cash net */
  38.  
  39.